<template>
    <eui-page-frame :topHeight="70">
        <template #top>
            <view class="content-img">
                <eui-navbar ref="euiNavBar" title="单据列表" color="#000000" backgroundColor="#FFFFFF">
                </eui-navbar>
            </view>
        </template>
        <eui-page-content>
            <eui-card title="商品信息" type="detail">
                <view v-for="(item, index) in dateList" :key="index">
                    <view class="m-list-top" @click="onClickGdsInfo(item)">
                        <eui-text v-model="item.c_po_id" :title="`${index+1}. 单号`" type="name" occupy/>
                        <eui-text v-model="item.c_provider" :name="getRelatedName('rdsProviders',item.c_provider)"
                                  type="titlename" title="供应商" occupy/>
                        <eui-text v-model="item.c_n_order" type="price" title="订货数量(含赠品)"/>
                        <eui-text v-model="item.c_at_pay_order" type="price" title="结算金额"/>
                    </view>
                </view>
            </eui-card>
        </eui-page-content>
    </eui-page-frame>
</template>

<script setup type="ts">
import {ref, reactive, onMounted} from 'vue';
import service from '@/common/service'
import {getRelatedName} from '../../../components/RelatedName.js';
import {onLoad} from "@dcloudio/uni-app";
import {getRdsUrl, rdsRequest} from "@/hooks/rdsServices";

const rdsUrl = getRdsUrl();
const dateList = ref([]);
const c_status = ref('3'); //审核状态
const c_summary = ref('0,1,2');//收货状态
const c_store_id = ref('');

onLoad(async (option) => {
    c_store_id.value = option.storeId;
    if (option.orderData) {
        dateList.value = JSON.parse(option.orderData);
    } else {
        service.enjoyShowLoading('正在加载...');
        await billList(option.poId);
        service.enjoyHideLoading();
    }
    
});
// 查询数据列表
const billList = async (billId) => {
    const req = {
        WhereList: [
            this.c_id ? {c_col: "c_id", c_oper: "等于", c_value: this.c_id, c_logic: "而且"} : {},
            {c_col: "c_store_id", c_oper: "等于", c_value: c_store_id.value, c_logic: "而且"},
            {c_col: "c_status", c_oper: "等于", c_value: '0', c_logic: "而且"},
            {c_col: "c_po_type", c_oper: "等于", c_value: '521', c_logic: "而且"}
        ]
    };
    if (this.c_master.c_po_id) {
        req.WhereList.push(
            {c_col: "c_po_id", c_oper: "等于", c_value: billId, c_logic: "而且"}
        )
    }
    const result = await rdsRequest(rdsUrl.scApi, '商品验收单', 'EnjoyQueryList', req, '701');
    const data = result.ReturnObject;
    this.dateList = data.ReturnObject;
};
// 筛选功能名称
const onClickGdsInfo = async (param) => {
    let pages = getCurrentPages(); //获取所有页面栈实例列表
    let prevPage = pages[pages.length - 2]; //上一页页面实例
    prevPage.$vm.$.exposed.SelectionChanged("poId", param); //执行函数也是同理
    await uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
        delta: 1
    });
};
</script>

<style lang="scss" scoped>

.m-list-top {
    width: 100%;
    display: grid;
    grid-template-columns: 51% 49%;
    border-bottom: 1px solid #c8c7cc;
    font-size: 12px;
}
</style>
